-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Simplify trivial constants in SimplifyConstCondition #147654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Simplify trivial constants in SimplifyConstCondition
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (2d02757): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 475.312s -> 475.552s (0.05%) |
3877315
to
dcd9af0
Compare
@bors2 try parent=last @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Simplify trivial constants in SimplifyConstCondition
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (2b77d79): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 475.312s -> 474.926s (-0.08%) |
let mut patch = MirPatch::new(body); | ||
|
||
'blocks: for (bb, block) in body.basic_blocks.iter_enumerated() { | ||
let mut pre_local_const: Option<(Local, &'_ ConstOperand<'_>)> = None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only locals and not any non-indirect place?
Do you mind adding a comment explaining this is safe as it only lives for a single statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An indirect place should also be safe. I cannot find a real-world case for non-locals by running ./x build --stage 2
, but checking place makes code simpler.
} else if let StatementKind::Assign(box (ref lhs, ref rvalue)) = stmt.kind | ||
&& let Some(local) = lhs.as_local() | ||
&& let Rvalue::Use(Operand::Constant(c)) = rvalue | ||
&& c.const_.ty().is_bool() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this condition useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
c | ||
} else { | ||
continue; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use something like this in terminators too?
TerminatorKind::SwitchInt { .. } | ||
| TerminatorKind::Goto { .. } | ||
| TerminatorKind::Unreachable | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this match exhaustive?
e3eec7c
to
64c5566
Compare
64c5566
to
8f854f8
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit. r=me once CI is fixed.
TerminatorKind::UnwindResume | ||
| TerminatorKind::UnwindTerminate(_) | ||
| TerminatorKind::Drop { .. } | ||
| TerminatorKind::Call { .. } | ||
| TerminatorKind::TailCall { .. } | ||
| TerminatorKind::Assert { .. } | ||
| TerminatorKind::Yield { .. } | ||
| TerminatorKind::CoroutineDrop | ||
| TerminatorKind::FalseEdge { .. } | ||
| TerminatorKind::FalseUnwind { .. } | ||
| TerminatorKind::InlineAsm { .. } => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move all terminators that don't write to memory to true
?
After
InstSimplify-after-simplifycfg
with-Zub_checks=false
, there are many of the following patterns.Simplifying them to unreachable early should make CFG simpler.